package com.lovegu.book.concurrence;

/**
 * @author 老顾
 * @title: ThreadPrority
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/11/5 8:50
 */
public class ThreadPriority {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+
                "("+Thread.currentThread().getPriority()+")");
        Thread t1 = new MyThead("t1");
        Thread t2 = new MyThead("t2");
        t1.setPriority(1);
        t2.setPriority(10);
        t1.start();
        t2.start();
    }
}
class MyThead extends Thread {
    public MyThead(String name){
        super(name);
    }
    @Override
    public void run(){
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()
            +"("+Thread.currentThread().getPriority()+")"
            +", loop"+i);
        }
    }
}